import { IParam } from '../../common/i-param';
import { ICtrlAbility } from '../ability';

/**
 * 部件事件
 *
 * @export
 * @interface ICtrlEvent
 * @template A
 */
export interface ICtrlEvent<T, A extends ICtrlAbility> {
	/**
	 * 部件行为
	 *
	 * @param {string} name
	 * @param {T} action
	 * @param {IParam[]} data
	 * @memberof ICtrlEvent
	 */
	ctrlAction(name: string, action: T, data: IParam[]): void;

	/**
	 * 部件初始化
	 *
	 * @param {string} name
	 * @param {A} data
	 * @memberof ICtrlEvent
	 */
	ctrlInit(name: string, data: A): void;

	/**
	 * 部件销毁
	 *
	 * @param {string} name
	 * @param {IParam} data
	 * @memberof ICtrlEvent
	 */
	ctrlDestroy(name: string, data: IParam): void;
}

//  部件事件行为类型
export type CtrlActionType = 'startLoad' | 'endLoad';

//  应用菜单部件事件行为类型
export type AppMenuActionType =
	| 'beforeLoad'
	| 'load'
	| 'loaded'
	| CtrlActionType;

//  应用看板部件事件行为类型
export type DashboardActionType = CtrlActionType | 'load';

//  实体部件行为类型
export type DECtrlActionType =
	| 'load'
	| 'beforeLoad'
	| 'dataActive'
	| CtrlActionType;

//  表单部件事件行为类型
export type FormActionType = 'loadDraft' | 'save' | DECtrlActionType;

//  编辑表单事件行为类型
export type EditFormActionType = 'remove' | 'dataChange' | FormActionType;

//  搜索表单部件行为类型
export type SearchFormActionType = 'search' | 'reSet' | FormActionType;

//  数据关系栏部件事件行为类型
export type DrbarActionType = 'selectionChange' | CtrlActionType;

//  数据关系分页栏部件事件行为类型
export type DrtabActionType =
	| 'selectionChange'
	| 'ctrlMounted'
	| CtrlActionType;

//  多数据部件行为类型
export type MDCtrlActionType = 'selectionChange' | DECtrlActionType;

// 导航部件行为类型
export type ExpCtrlActionType = 'selectionChange' | DECtrlActionType;

//  表格部件事件行为类型
export type GridActionType = 'save' | 'remove' | MDCtrlActionType;

//  列表部件事件行为类型
export type ListActionType = 'save' | 'remove' | MDCtrlActionType;

//  看板部件事件行为类型
export type KanBanActionType = 'save' | 'remove' | MDCtrlActionType;

//  卡片视图部件事件行为类型
export type DataViewCtrlActionType = 'save' | 'remove' | MDCtrlActionType;

//  日历部件事件行为类型
export type CalendarActionType = MDCtrlActionType | 'refetchEvents';

//  多表单编辑面板事件行为类型
export type MultiEditViewPanelActionType = 'remove' | 'add' | MDCtrlActionType;

//  图表部件事件行为类型
export type ChartActionType =
	| 'refresh'
	| 'updateSize'
	| 'selectionChange'
	| MDCtrlActionType;

//  选择视图面板部件行为类型
export type PickupViewPanelActionType = 'selectionChange' | DECtrlActionType;

//  树视图部件事件行为类型
export type TreeActionType = MDCtrlActionType;

//  树导航栏部件事件行为类型
export type TreeExpBarActionType = ExpCtrlActionType;

//  表格导航栏部件事件行为类型
export type GridExpBarActionType = ExpCtrlActionType;

//  列表导航栏部件事件行为类型
export type ListExpBarActionType = ExpCtrlActionType;

//  分页导航面板部件事件行为类型
export type TabExpPanelActionType = 'tabClick' | CtrlActionType;

//  分页视图面板部件事件行为类型
export type TabViewPanelActionType = CtrlActionType;

//  日历导航栏部件事件行为类型
export type CalendarExpBarActionType = ExpCtrlActionType;

//  面板部件事件行为类型
export type PanelActionType = MDCtrlActionType;

//  向导面板部件事件行为类型
export type WizardPanelActionType = DECtrlActionType | 'doFinish';

//  门户部件事件行为类型
export type PortletActionType = DECtrlActionType;

//  报表面板部件事件行为类型
export type ReportPanelActionType = MDCtrlActionType;
